﻿#include "LevelUtils.h"
#include <math.h>
using namespace std;
LevelUtils* LevelUtils::pInstance = nullptr;
LevelUtils::LevelUtils() {

}

/*
	获取怪物数量
*/
int LevelUtils::getEnemyCount(int level) {
	int gameLevel = level / 5 + 1;
	int enemyCount = gameLevel * 5 + level / 2;
	return enemyCount;
}

/*
	获取怪物难度
*/
vector<int> LevelUtils::getEnemyLevel(int level) {
	int enemyCount = getEnemyCount(level);
	//int gameLevel = level / 5 + 1;
	vector<int> enemyLevels;
	for (size_t i = 1; i <= enemyCount; i++) {
		if (i % 3 == 0) {
			enemyLevels.push_back(2);
		} else if (i % 7 == 0) {
			enemyLevels.push_back(3);
		}else {
			enemyLevels.push_back(1);
		}
	}
	return enemyLevels;
}

int LevelUtils::getTotalEnemyCount(int level) {
	int enemyCount = getEnemyCount(level);
	vector<int> enemyLevels = getEnemyLevel(level);
	int total = 0;
	for (size_t i = 0; i < enemyCount; i++) {
		total += pow(2, enemyLevels[i]) - 1;
	}
	return total;
}